package com.hzcx.app.simplechat.ui.setting;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseActivity;
import com.hzcx.app.simplechat.ui.publicui.SendCodeActivity;
import com.hzcx.app.simplechat.ui.publicui.enums.SendCodeEnum;
import com.hzcx.app.simplechat.ui.setting.event.UpdatePhoneEvent;
import com.hzcx.app.simplechat.util.UserInfoUtil;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 我的手机号页面
 */
public class MinePhoneActivity extends BaseActivity {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    @BindView(R.id.tv_title_right)
    TextView tvTitleRight;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.tv_update)
    TextView tvUpdate;

    @Override
    public int getLayout() {
        return R.layout.activity_mine_phone;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        tvTitle.setText("绑定手机号");

        tvPhone.setText(UserInfoUtil.getUserPhone());
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.tv_update})
    public void viewOnClick(View view) {
        switch (view.getId()) {
            case R.id.tv_update:
                startActivity(new Intent(this, SendCodeActivity.class)
                        .putExtra(SendCodeActivity.INTENT_PHONE, UserInfoUtil.getUserPhone())
                        .putExtra(SendCodeActivity.INTENT_PHONE_CITY, UserInfoUtil.getUserPhoneCityCode())
                        .putExtra(SendCodeActivity.INTENT_EUNM, SendCodeEnum.UPDATE_PHONE));
                break;
        }
    }

    /**
     *  修改手机号成功
     * @param event
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void updatePhoneSuccess(UpdatePhoneEvent event){
        tvPhone.setText(UserInfoUtil.getUserPhone());
    }

}
